<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title><%= title %></title>
  <%include include/head.ejs %>
</head>
<body>
<!--登录注册盒子-->
<div class="login_panel">
	<!--登录注册选项卡-->
  <div class="login_titleBox">
      <div class="login_title active" data_href="#login">登陆</div>
      <div class="login_title" data_href="#regist">注册</div>
  </div>
	<div class="tab_content">
		<!--登录-->
		<div class="active" id="login">
			<div class="form_row_line">
				<label class="control-label" for="loginName">
					<span>用户</span>
					<input type="text" id="loginName" placeholder="请输入用户名">
				</label>
			</div>
			<div class="form_row_line">
				<label class="control-label" for="loginPwd">
					<span>密码</span>
					<input type="password" id="loginPwd" placeholder="请输入密码">
				</label>
			</div>
			<div class="form_row_line">
				<div class="btn btn_block" id="loginSub">登陆</div>
			</div>
		</div>
		<!--注册-->
		<div id="regist">
			<div class="form_row_line">
				<label class="control-label" for="registName">
					<span>用户</span>
					<input type="text" id="registName" placeholder="请输入你需要注册的用户名">
				</label>
			</div>
			<div class="form_row_line">
				<label class="control-label" for="registPwd">
					<span>密码</span>
					<input type="password" id="registPwd" placeholder="请输入你的注册密码">
				</label>
			</div>
			<div class="form_row_line">
				<div class="btn btn_block" id="registSub">注册</div>
			</div>
		</div>
	</div>
</div>





</body>
<script type="text/javascript">
  $(function(){
		//选项卡切换
	  $(".login_titleBox .login_title").click(function(){
	    $(this).addClass("active").siblings(".login_title").removeClass("active");
	    var href = $(this).attr("data_href"),siblingHref = $(this).siblings(".login_title").attr("data_href");
	    $(href).addClass("active");
	    $(siblingHref).removeClass("active");
	  });
    //登陆
    var loginInfo = {name:"", password:""};
    $("#loginSub").click(function(){
      loginInfo.name = $("#loginName").val();
      loginInfo.password = $("#loginPwd").val();
      $.post("/loginregist/login",loginInfo,function(data){
        location.href=data;
      });
    });
    //注册
	  var registInfo = {name:"",password:""}
	  $("#registSub").click(function(){
      registInfo.name = $("#registName").val();
      registInfo.password = $("#registPwd").val();
      if(registInfo.name == ""){
        alert("用户名不能为空");
      }else if(registInfo.password == ""){
        alert("密码不能为空");
      }else{
        $.post("/loginregist/regist",registInfo,function(data){
          if(data.success == true){
            location.reload();
          }else{
            alert(data);
          }
        });
      }
	  })
  });
</script>
</html>